home *** CD-ROM | disk | FTP | other *** search
- Path: news.ner.bbnplanet.net!forest!groy
- From: groy@forest.drew.edu (I can't think of a nickname)
- Newsgroups: comp.lang.c
- Subject: HELP!!!! --very important!!--
- Message-ID: <1996Mar21.000242.138161@forest>
- Date: 21 Mar 96 00:02:42 EST
- Organization: Drew University
-
- Please Help....
- I need to get this program working... the function set_diff is supposed to
- find the differences between the two arrays (a[] and b[]) and put the
- differences(if any) in array c[]....
-
- int set_diff(int a[], int b[], int c[], int max) {
- int *first = a;
- int *second = b;
- int *third = c;
- int *endfirst = first + max;
- int *endsecond = second + max;
- int count=0;
- /*first compare each value of a to b and note the differences*/
-
- for(first = a,second = b; first< endfirst, second<endsecond;
- first++,second++){
- if (*first == *second)
- count =1;
-
- if (count != 1){
- *third = *first;
- third++; } count =0;
- } /* end of for(first ... */
- return count;
- } /*end of set_diff */
- int main () {
- int a[MAX], b[MAX], c[MAX * 2]; /*the three arrays */
- int count;
- int decide;
-
- printf("Enter %i integers \n",MAX);
-
- for (count = 0; count < MAX; count++)
- scanf("%i", &a[count]);
- printf("Enter %i more integers \n",MAX);
- for (count =0; count < MAX; count++)
- scanf("%i", &b[count]);
- decide =set_diff(a, b, c, MAX);
- /* now print the three arrays */
- printf("array a\n");
- for(count = 0; count < MAX; count++)
- printf("%2i ", a[count]);
- printf("\narray b\n");
- for(count = 0; count < MAX; count++)
- printf("%2i ", b[count]);
- if (decide != 1) {
- printf("\ndifference\n");
- for(count = 0; count < (MAX * 2); count++)
- printf("%2i ", c[count]); }
- printf("\n");
- } /*end of main*/
-
-
-
-
-
- Thankyou for any help.. please hurry I am running out of time...
-
-
-
- Ps.. there are probbly two more programs on the way...
- Greg Roy
- Groy@drew.edu
-
-
-